﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using CodeFirstMVC3.DataAccess.Model;

namespace CodeFirstMVC3.Web.Infrastructure
{
    public class CodeFirstDbInitializer : DropCreateDatabaseAlways<CodeFirstDbContext>
    {
        protected override void Seed(CodeFirstDbContext context)
        {
            new List<User>
            {
                new User { 
                    Firstname = "arash",
                    Lastname = "karami",
                    Member = new Member { 
                        Username = "arka",
                        Password = "123",
                        Active = true, 
                        Role = new Role { 
                            Name = "admin",
                            Active = true 
                        }
                    },
                    Job = new Job { 
                        Name = "coder" 
                    }
                },
                new User { 
                    Firstname = "bill",
                    Lastname = "gates",
                    Member = new Member { 
                        Username = "Bill",
                        Password = "456",
                        Active = true, 
                        Role = new Role { 
                            Name = "user",
                            Active = true 
                        }
                    },
                    Job = new Job { 
                        Name = "Manager @ microsoft" 
                    }
                }
            }.ForEach(u => context.Users.Add(u));

            base.Seed(context);
        }
    }
}